<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 *
 * @Date: 2017-06-07
 * @Time: 12:40
 * @Author: cdkay
 * @Email: network@iyuanma.net
 *
 * @File： Acl.php
 */
class Acl extends MY_Controller {
    public function __construct()
    {
        parent::__construct();

        $this->load->model('system/Acl_model');
    }

    /**
     * index
     * 权限管理列表页
     */
    public function index()
    {
        $data['acl'] = $this->Acl_model->get_all_acl();

        $this->load->view('system/acl/index', $data);
    }

    /**
     * add
     * 添加权限
     */
    public function add()
    {
        $data['menu_parent'] = $this->Acl_model->menu_parent_get();

        //取得所有控制器
        $data['controller'] = getAllController();

        $this->load->view('system/acl/add', $data);
    }

    /**
     * edit
     * 编辑权限
     *
     * @param int $acl_id 权限节点id
     */
    public function edit($acl_id)
    {
        $data['menu_parent'] = $this->Acl_model->menu_parent_get();

        $data['acl'] = $this->Acl_model->get_single_acl($acl_id);

        //取得所有控制器
        $data['controller'] = getAllController();

        $this->load->view('system/acl/edit', $data);
    }

    /**
     * save
     * 保存权限数据 添加|编辑
     */
    public function save()
    {
        if (!IS_POST) exit();

        $result = $this->Acl_model->acl_save();

        exit(json_encode($result));
    }

    /**
     * del
     * 删除权限
     */
    public function del()
    {
        $result = $this->Acl_model->acl_delete();

        exit(json_encode($result));
    }
}